package com.bootcamp.servlet.binary;

/**
 * @program: wrok-1101
 * @description: 当访问该servlet时候，将1.jpg返回给浏览器
 * @author: Keyu Li
 * @create: 2021-11-02 11:43
 **/

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.FileInputStream;
import java.io.IOException;

@WebServlet(name = "ByteSendServlet", value = "/bytestream")
public class ByteSendServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 获取文件输入流
        String imgPath = request.getServletContext().getRealPath("1.jpg");
        FileInputStream fileInputStream = new FileInputStream(imgPath);
        // 将获得到的文件输入流 输出到 servlet输出流

    }
}
